package com.xiaoshuidi.cloud.module.contract.enums.contract;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * 合同模板类型的枚举类
 *
 * @author 合房源码
 */
@Getter
@AllArgsConstructor
public enum ContractTemplateTypeEnum {

    RENT_CONTRACT("rent", "租客合同"),
    OWNER_HOUSE_CONTRACT("owner", "业主合同");
    private String code;
    private String msg;

    public static String getMsgByCode(String code) {
        if (code == null) {
            return "";
        }
        Optional<String> first = Arrays.stream(ContractTemplateTypeEnum.values()).filter(s -> s.getCode().equals(code)).map(s -> s.getMsg()).findFirst();
        if (first.isPresent()) {
            return first.get();
        }
        return "";
    }
}
